package com.util
{
	import flash.display.Bitmap;
	import flash.utils.getDefinitionByName;
	
	import com.game.raceroom.player.item.BaseItem;
	public class ImgUtil
	{
		
		
		[Embed(source='assets/main/raceroom/userstatus/str.jpg')]
        private static const Misc_str:Class;	
		[Embed(source='assets/main/raceroom/userstatus/blood.jpg')]
        private static const Misc_bld:Class;	
		public static function getMiscImg(name:String):Bitmap{
			try{
	            var P:Class = getDefinitionByName("com.util.ImgUtil_Misc_"+name) as Class;
	            if(P==null)return new Bitmap;
	            return new P as Bitmap;
            }catch(e:Error){
            }
            return getDftIcon();
			 
		}
		//default 
		[Embed(source='assets/default.png')]
        private static const DftIcon:Class;
		public static function getDftIcon():Bitmap{

            return new DftIcon as Bitmap;
			 
		}
		  
        //userIcon part
        //[Embed(source='assets/main/userinfo/icon/1.png')]
        //private static const UserIcon_1:Class;
        //[Embed(source='assets/main/userinfo/icon/2.png')]
        //private static const UserIcon_2:Class;
        [Embed(source='assets/main/userinfo/icon/1.gif')]
        private static const UserIcon_3:Class;
        //[Embed(source='assets/main/userinfo/icon/4.png')]
        //private static const UserIcon_4:Class;
		public static function getUserIcon(id:int):Bitmap{
			try{
	            var P:Class = getDefinitionByName("com.util.ImgUtil_UserIcon_"+id) as Class;
	            if(P==null)return new Bitmap;
	            return new P as Bitmap;
            }catch(e:Error){
            }
            return getDftIcon();
			 
		}
		
		
		
		//car part
        [Embed(source='assets/items/car/31000.png')]
        private static const CarIcon_31000:Class;
        [Embed(source='assets/items/car/31001.png')]
        private static const CarIcon_31001:Class;
        [Embed(source='assets/items/car/32000.png')]
        private static const CarIcon_32000:Class;
        [Embed(source='assets/items/car/33000.png')]
        private static const CarIcon_33000:Class;
        [Embed(source='assets/items/car/33001.png')]
        private static const CarIcon_33001:Class;
        [Embed(source='assets/items/car/34000.png')]
        private static const CarIcon_34000:Class;
        [Embed(source='assets/items/car/34001.png')]
        private static const CarIcon_34001:Class;
         [Embed(source='assets/items/car/35000.png')]
        private static const CarIcon_35000:Class;
        [Embed(source='assets/items/car/36000.png')]
        private static const CarIcon_36000:Class;
        [Embed(source='assets/items/car/37000.png')]
        private static const CarIcon_37000:Class;

		public static function getCarIcon(id:int):Bitmap{
            try{
	            var P:Class = getDefinitionByName("com.util.ImgUtil_CarIcon_"+id) as Class;
	            if(P==null)return new Bitmap;
	            return new P as Bitmap;
            }catch(e:Error){
            	
            }
            return getDftIcon();
		}
		
		//item part
        [Embed(source='assets/items/item/11000.png')]
        private static const ItemIcon_11000:Class;
        [Embed(source='assets/items/item/11010.png')]
        private static const ItemIcon_11010:Class;
        [Embed(source='assets/items/item/11020.png')]
        private static const ItemIcon_11020:Class;
        [Embed(source='assets/items/item/11030.png')]
        private static const ItemIcon_11030:Class;
        [Embed(source='assets/items/item/11040.png')]
        private static const ItemIcon_11040:Class;
        [Embed(source='assets/items/item/11050.png')]
        private static const ItemIcon_11050:Class;
		public static function getItemIcon(id:int):Bitmap{
            try{
	            var P:Class = getDefinitionByName("com.util.ImgUtil_ItemIcon_"+id) as Class;
	            if(P==null)return new Bitmap;
	            return new P as Bitmap;
            }catch(e:Error){
            	
            }
            return getDftIcon();
		}
		
        [Embed(source='assets/items/part/20000.png')]
        private static const PartIcon_20000:Class;
        [Embed(source='assets/items/part/21000.png')]
        private static const PartIcon_21000:Class;
        [Embed(source='assets/items/part/22000.png')]
        private static const PartIcon_22000:Class;
        [Embed(source='assets/items/part/23000.png')]
        private static const PartIcon_23000:Class;
        [Embed(source='assets/items/part/24000.png')]
        private static const PartIcon_24000:Class;
        [Embed(source='assets/items/part/25000.png')]
        private static const PartIcon_25000:Class; 
                               
		public static function getPartIcon(id:int):Bitmap{
            try{
	            var P:Class = getDefinitionByName("com.util.ImgUtil_PartIcon_"+id) as Class;
	            if(P==null)return new Bitmap;
	            return new P as Bitmap;
            }catch(e:Error){
            	
            }
            return getDftIcon();
		}
		 
		public static function getAnyItemIcon(itm:BaseItem):Bitmap{
             if(itm.itype==0){
             	return getItemIcon(itm.iid);
             }
             if(itm.itype==1){
             	return getPartIcon(itm.iid);
             }
             if(itm.itype==2){
             	return getCarIcon(itm.iid);
             }
             return getDftIcon();
		}
	}
}